static char *output_dir = NULL;
+static gboolean debug;
+
static GOptionEntry args[] = {
{ "output", 'o', 0, G_OPTION_ARG_FILENAME, &output_dir, N_("Output to this directory instead of cwd"), NULL },
+ { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Generate debug output") },
{ NULL }
};
g_set_prgname ("gtk-encode-symbolic-svg");
- context = g_option_context_new ("PATH WIDTHxHEIGHT");
+ context = g_option_context_new ("[OPTION…] PATH WIDTHxHEIGHT");
g_option_context_add_main_entries (context, args, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, NULL);
return 1;
}
- symbolic = gtk_make_symbolic_pixbuf_from_data (data, len, width, height, 1.0, &error);
+ basename = g_path_get_basename (path);
+
+ symbolic = gtk_make_symbolic_pixbuf_from_data (data, len, width, height, 1.0, debug ? basename : NULL, &error);
if (symbolic == NULL)
{
g_printerr (_("Can’t load file: %s\n"), error->message);
g_free (data);
- basename = g_path_get_basename (path);
-
dot = strrchr (basename, '.');
if (dot != NULL)
*dot = 0;
int width,
int height,
double scale,
+ const char *debug_output_basename,
GError **error)
{
if (loaded == NULL)
goto out;
+ if (debug_output_basename)
+ {
+ char *filename;
+
+ filename = g_strdup_printf ("%s.debug%d.png", debug_output_basename, plane);
+ g_print ("Writing %s\n", filename);
+ gdk_pixbuf_save (loaded, filename, "png", NULL, NULL);
+ g_free (filename);
+ }
+
if (pixbuf == NULL)
{
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
data = g_bytes_get_data (bytes, &size);
- pixbuf = gtk_make_symbolic_pixbuf_from_data (data, size, width, height, scale, error);
+ pixbuf = gtk_make_symbolic_pixbuf_from_data (data, size, width, height, scale, NULL, error);
g_bytes_unref (bytes);
if (!g_file_get_contents (path, &data, &size, error))
return NULL;
- pixbuf = gtk_make_symbolic_pixbuf_from_data (data, size, width, height, scale, error);
+ pixbuf = gtk_make_symbolic_pixbuf_from_data (data, size, width, height, scale, NULL, error);
g_free (data);
if (!g_file_load_contents (file, NULL, &data, &size, NULL, error))
return NULL;
- pixbuf = gtk_make_symbolic_pixbuf_from_data (data, size, width, height, scale, error);
+ pixbuf = gtk_make_symbolic_pixbuf_from_data (data, size, width, height, scale, NULL, error);
g_free (data);